/**
 * Selling Partner API for Messaging
 * With the Messaging API you can build applications that send messages to buyers. You can get a list of message types that are available for an order that you specify, then call an operation that sends a message to the buyer for that order. The Messaging API returns responses that are formed according to the <a href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.
 *
 * The version of the OpenAPI document: v1
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 *
 */

import { ApiClient } from '../ApiClient.js'
import { CreateAmazonMotorsRequest } from '../model/CreateAmazonMotorsRequest.js'
import { CreateAmazonMotorsResponse } from '../model/CreateAmazonMotorsResponse.js'
import { CreateConfirmCustomizationDetailsRequest } from '../model/CreateConfirmCustomizationDetailsRequest.js'
import { CreateConfirmCustomizationDetailsResponse } from '../model/CreateConfirmCustomizationDetailsResponse.js'
import { CreateConfirmDeliveryDetailsRequest } from '../model/CreateConfirmDeliveryDetailsRequest.js'
import { CreateConfirmDeliveryDetailsResponse } from '../model/CreateConfirmDeliveryDetailsResponse.js'
import { CreateConfirmOrderDetailsRequest } from '../model/CreateConfirmOrderDetailsRequest.js'
import { CreateConfirmOrderDetailsResponse } from '../model/CreateConfirmOrderDetailsResponse.js'
import { CreateConfirmServiceDetailsRequest } from '../model/CreateConfirmServiceDetailsRequest.js'
import { CreateConfirmServiceDetailsResponse } from '../model/CreateConfirmServiceDetailsResponse.js'
import { CreateDigitalAccessKeyRequest } from '../model/CreateDigitalAccessKeyRequest.js'
import { CreateDigitalAccessKeyResponse } from '../model/CreateDigitalAccessKeyResponse.js'
import { CreateLegalDisclosureRequest } from '../model/CreateLegalDisclosureRequest.js'
import { CreateLegalDisclosureResponse } from '../model/CreateLegalDisclosureResponse.js'
import { CreateUnexpectedProblemRequest } from '../model/CreateUnexpectedProblemRequest.js'
import { CreateUnexpectedProblemResponse } from '../model/CreateUnexpectedProblemResponse.js'
import { CreateWarrantyRequest } from '../model/CreateWarrantyRequest.js'
import { CreateWarrantyResponse } from '../model/CreateWarrantyResponse.js'
import { GetAttributesResponse } from '../model/GetAttributesResponse.js'
import { GetMessagingActionsForOrderResponse } from '../model/GetMessagingActionsForOrderResponse.js'
import { InvoiceRequest } from '../model/InvoiceRequest.js'
import { InvoiceResponse } from '../model/InvoiceResponse.js'
import { SuperagentRateLimiter } from '../../../helper/SuperagentRateLimiter.mjs'
import { DefaultRateLimitFetcher } from '../../../helper/DefaultRateLimitFetcher.mjs'

/**
* Messaging service.
* @module messaging_v1/api/MessagingApi
* @version v1
*/
export class MessagingApi {
  // Private member stores the default rate limiters
  #defaultRateLimiterMap

  /**
    * Constructs a new MessagingApi.
    * @alias module:messaging_v1/api/MessagingApi
    * @class
    * @param {ApiClient} [apiClient] Optional API client implementation to use,
    * default to {@link ApiClient#instance} if unspecified.
    */
  constructor (apiClient) {
    this.apiClient = apiClient || ApiClient.instance
    this.initializeDefaultRateLimiterMap()
  }

  /**
     * Initialize rate limiters for API operations
     */
  initializeDefaultRateLimiterMap () {
    this.#defaultRateLimiterMap = new Map()
    const defaultRateLimitFetcher = new DefaultRateLimitFetcher()
    const operations = [
      'MessagingApi-confirmCustomizationDetails',
      'MessagingApi-createAmazonMotors',
      'MessagingApi-createConfirmDeliveryDetails',
      'MessagingApi-createConfirmOrderDetails',
      'MessagingApi-createConfirmServiceDetails',
      'MessagingApi-createDigitalAccessKey',
      'MessagingApi-createLegalDisclosure',
      'MessagingApi-createUnexpectedProblem',
      'MessagingApi-createWarranty',
      'MessagingApi-getAttributes',
      'MessagingApi-getMessagingActionsForOrder',
      'MessagingApi-sendInvoice'
    ]

    for (const operation of operations) {
      const config = defaultRateLimitFetcher.getLimit(operation)
      this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config))
    }
  }

  /**
     * Get rate limiter for a specific operation
     * @param {String} operation name
     */
  getRateLimiter (operation) {
    return this.#defaultRateLimiterMap.get(operation)
  }

  /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images, initials, etc.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmCustomizationDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmCustomizationDetailsResponse>}
     */
  confirmCustomizationDetailsWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling confirmCustomizationDetails")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling confirmCustomizationDetails")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling confirmCustomizationDetails")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateConfirmCustomizationDetailsResponse

    return this.apiClient.callApi('MessagingApi-confirmCustomizationDetails',
      '/messaging/v1/orders/{amazonOrderId}/messages/confirmCustomizationDetails', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-confirmCustomizationDetails')
    )
  }

  /**
     * Sends a message asking a buyer to provide or verify customization details such as name spelling, images, initials, etc.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmCustomizationDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmCustomizationDetailsResponse>}
     */
  confirmCustomizationDetails (amazonOrderId, marketplaceIds, body) {
    return this.confirmCustomizationDetailsWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by Amazon Motors sellers.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateAmazonMotorsRequest} body This contains the message body for a message.
     * @return {Promise<CreateAmazonMotorsResponse>}
     */
  createAmazonMotorsWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createAmazonMotors")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createAmazonMotors")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createAmazonMotors")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateAmazonMotorsResponse

    return this.apiClient.callApi('MessagingApi-createAmazonMotors',
      '/messaging/v1/orders/{amazonOrderId}/messages/amazonMotors', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createAmazonMotors')
    )
  }

  /**
     * Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by Amazon Motors sellers.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateAmazonMotorsRequest} body This contains the message body for a message.
     * @return {Promise<CreateAmazonMotorsResponse>}
     */
  createAmazonMotors (amazonOrderId, marketplaceIds, body) {
    return this.createAmazonMotorsWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmDeliveryDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmDeliveryDetailsResponse>}
     */
  createConfirmDeliveryDetailsWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createConfirmDeliveryDetails")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createConfirmDeliveryDetails")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createConfirmDeliveryDetails")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateConfirmDeliveryDetailsResponse

    return this.apiClient.callApi('MessagingApi-createConfirmDeliveryDetails',
      '/messaging/v1/orders/{amazonOrderId}/messages/confirmDeliveryDetails', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createConfirmDeliveryDetails')
    )
  }

  /**
     * Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmDeliveryDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmDeliveryDetailsResponse>}
     */
  createConfirmDeliveryDetails (amazonOrderId, marketplaceIds, body) {
    return this.createConfirmDeliveryDetailsWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmOrderDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmOrderDetailsResponse>}
     */
  createConfirmOrderDetailsWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createConfirmOrderDetails")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createConfirmOrderDetails")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createConfirmOrderDetails")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateConfirmOrderDetailsResponse

    return this.apiClient.callApi('MessagingApi-createConfirmOrderDetails',
      '/messaging/v1/orders/{amazonOrderId}/messages/confirmOrderDetails', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createConfirmOrderDetails')
    )
  }

  /**
     * Sends a message to ask a buyer an order-related question prior to shipping their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmOrderDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmOrderDetailsResponse>}
     */
  createConfirmOrderDetails (amazonOrderId, marketplaceIds, body) {
    return this.createConfirmOrderDetailsWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a service call.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmServiceDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmServiceDetailsResponse>}
     */
  createConfirmServiceDetailsWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createConfirmServiceDetails")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createConfirmServiceDetails")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createConfirmServiceDetails")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateConfirmServiceDetailsResponse

    return this.apiClient.callApi('MessagingApi-createConfirmServiceDetails',
      '/messaging/v1/orders/{amazonOrderId}/messages/confirmServiceDetails', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createConfirmServiceDetails')
    )
  }

  /**
     * Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a service call.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateConfirmServiceDetailsRequest} body This contains the message body for a message.
     * @return {Promise<CreateConfirmServiceDetailsResponse>}
     */
  createConfirmServiceDetails (amazonOrderId, marketplaceIds, body) {
    return this.createConfirmServiceDetailsWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateDigitalAccessKeyRequest} body This contains the message body for a message.
     * @return {Promise<CreateDigitalAccessKeyResponse>}
     */
  createDigitalAccessKeyWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createDigitalAccessKey")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createDigitalAccessKey")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createDigitalAccessKey")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateDigitalAccessKeyResponse

    return this.apiClient.callApi('MessagingApi-createDigitalAccessKey',
      '/messaging/v1/orders/{amazonOrderId}/messages/digitalAccessKey', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createDigitalAccessKey')
    )
  }

  /**
     * Sends a buyer a message to share a digital access key that is required to utilize digital content in their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateDigitalAccessKeyRequest} body This contains the message body for a message.
     * @return {Promise<CreateDigitalAccessKeyResponse>}
     */
  createDigitalAccessKey (amazonOrderId, marketplaceIds, body) {
    return this.createDigitalAccessKeyWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This message should only be used to deliver documents that are required by law.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateLegalDisclosureRequest} body This contains the message body for a message.
     * @return {Promise<CreateLegalDisclosureResponse>}
     */
  createLegalDisclosureWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createLegalDisclosure")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createLegalDisclosure")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createLegalDisclosure")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateLegalDisclosureResponse

    return this.apiClient.callApi('MessagingApi-createLegalDisclosure',
      '/messaging/v1/orders/{amazonOrderId}/messages/legalDisclosure', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createLegalDisclosure')
    )
  }

  /**
     * Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer. This message should only be used to deliver documents that are required by law.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateLegalDisclosureRequest} body This contains the message body for a message.
     * @return {Promise<CreateLegalDisclosureResponse>}
     */
  createLegalDisclosure (amazonOrderId, marketplaceIds, body) {
    return this.createLegalDisclosureWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateUnexpectedProblemRequest} body This contains the message body for a message.
     * @return {Promise<CreateUnexpectedProblemResponse>}
     */
  createUnexpectedProblemWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createUnexpectedProblem")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createUnexpectedProblem")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createUnexpectedProblem")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateUnexpectedProblemResponse

    return this.apiClient.callApi('MessagingApi-createUnexpectedProblem',
      '/messaging/v1/orders/{amazonOrderId}/messages/unexpectedProblem', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createUnexpectedProblem')
    )
  }

  /**
     * Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateUnexpectedProblemRequest} body This contains the message body for a message.
     * @return {Promise<CreateUnexpectedProblemResponse>}
     */
  createUnexpectedProblem (amazonOrderId, marketplaceIds, body) {
    return this.createUnexpectedProblemWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateWarrantyRequest} body This contains the message body for a message.
     * @return {Promise<CreateWarrantyResponse>}
     */
  createWarrantyWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling createWarranty")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling createWarranty")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling createWarranty")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = CreateWarrantyResponse

    return this.apiClient.callApi('MessagingApi-createWarranty',
      '/messaging/v1/orders/{amazonOrderId}/messages/warranty', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-createWarranty')
    )
  }

  /**
     * Sends a message to a buyer to provide details about warranty information on a purchase in their order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {CreateWarrantyRequest} body This contains the message body for a message.
     * @return {Promise<CreateWarrantyResponse>}
     */
  createWarranty (amazonOrderId, marketplaceIds, body) {
    return this.createWarrantyWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Returns a response containing attributes related to an order. This includes buyer preferences.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @return {Promise<GetAttributesResponse>}
     */
  getAttributesWithHttpInfo (amazonOrderId, marketplaceIds) {
    const postBody = null

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling getAttributes")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling getAttributes")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = []
    const accepts = ['application/hal+json']
    const returnType = GetAttributesResponse

    return this.apiClient.callApi('MessagingApi-getAttributes',
      '/messaging/v1/orders/{amazonOrderId}/attributes', 'GET',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-getAttributes')
    )
  }

  /**
     * Returns a response containing attributes related to an order. This includes buyer preferences.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @return {Promise<GetAttributesResponse>}
     */
  getAttributes (amazonOrderId, marketplaceIds) {
    return this.getAttributesWithHttpInfo(amazonOrderId, marketplaceIds)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a message.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available message types.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @return {Promise<GetMessagingActionsForOrderResponse>}
     */
  getMessagingActionsForOrderWithHttpInfo (amazonOrderId, marketplaceIds) {
    const postBody = null

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling getMessagingActionsForOrder")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling getMessagingActionsForOrder")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = []
    const accepts = ['application/hal+json']
    const returnType = GetMessagingActionsForOrderResponse

    return this.apiClient.callApi('MessagingApi-getMessagingActionsForOrder',
      '/messaging/v1/orders/{amazonOrderId}', 'GET',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-getMessagingActionsForOrder')
    )
  }

  /**
     * Returns a list of message types that are available for an order that you specify. A message type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a message.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The &#x60;x-amzn-RateLimit-Limit&#x60; response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     * @param {String} amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available message types.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @return {Promise<GetMessagingActionsForOrderResponse>}
     */
  getMessagingActionsForOrder (amazonOrderId, marketplaceIds) {
    return this.getMessagingActionsForOrderWithHttpInfo(amazonOrderId, marketplaceIds)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }

  /**
     * Sends a message providing the buyer an invoice
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {InvoiceRequest} body This contains the message body for a message.
     * @return {Promise<InvoiceResponse>}
     */
  sendInvoiceWithHttpInfo (amazonOrderId, marketplaceIds, body) {
    const postBody = body

    // verify the required parameter 'amazonOrderId' is set
    if (amazonOrderId === undefined || amazonOrderId === null) {
      throw new Error("Missing the required parameter 'amazonOrderId' when calling sendInvoice")
    }

    // verify the required parameter 'marketplaceIds' is set
    if (marketplaceIds === undefined || marketplaceIds === null) {
      throw new Error("Missing the required parameter 'marketplaceIds' when calling sendInvoice")
    }

    // verify the required parameter 'body' is set
    if (body === undefined || body === null) {
      throw new Error("Missing the required parameter 'body' when calling sendInvoice")
    }

    const pathParams = {
      amazonOrderId
    }
    const queryParams = {
      marketplaceIds: this.apiClient.buildCollectionParam(marketplaceIds, 'csv')
    }
    const headerParams = {
    }
    const formParams = {
    }

    const contentTypes = ['application/json']
    const accepts = ['application/hal+json']
    const returnType = InvoiceResponse

    return this.apiClient.callApi('MessagingApi-sendInvoice',
      '/messaging/v1/orders/{amazonOrderId}/messages/invoice', 'POST',
      pathParams, queryParams, headerParams, formParams, postBody,
      contentTypes, accepts, returnType, this.getRateLimiter('MessagingApi-sendInvoice')
    )
  }

  /**
     * Sends a message providing the buyer an invoice
     * @param {String} amazonOrderId An Amazon order identifier. This identifies the order for which a message is sent.
     * @param {[String]} marketplaceIds A marketplace identifier. This identifies the marketplace in which the order was placed. You can only specify one marketplace.
     * @param {InvoiceRequest} body This contains the message body for a message.
     * @return {Promise<InvoiceResponse>}
     */
  sendInvoice (amazonOrderId, marketplaceIds, body) {
    return this.sendInvoiceWithHttpInfo(amazonOrderId, marketplaceIds, body)
      .then(function (response_and_data) {
        return response_and_data.data
      })
  }
}
